package jvm.singleton;

// 懒汉DCL
public class Mgr02 {
    private static volatile Mgr02 instance;

    private Mgr02() {

    }
    public static Mgr02 getInstance() {
        if (instance == null) {
            synchronized (Mgr02.class) {
                if (instance == null) {
                    instance = new Mgr02();
                }
            }
        }
        return instance;
    }

    public static void main(String[] args) {
        Mgr02 mgr01 = Mgr02.getInstance();
        Mgr02 mgr02 = Mgr02.getInstance();
        System.out.println(mgr02 == mgr01);
    }
}
